from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome()
driver.get('https://www.baidu.com/')
driver.maximize_window()
sleep(4)
handls1 = driver.current_window_handle
driver.find_element(By.LINK_TEXT,'新闻').click()
driver.find_element(By.LINK_TEXT,'文库').click()
handles_all = driver.window_handles
print(handles_all)
sleep(20)
for aa in handles_all:
    driver.switch_to.window(aa)
    if driver.title == "百度新闻-海量中文资讯":
      print(driver.title)
      break
assert_text = driver.find_element(By.LINK_TEXT,"热点要闻").text
print(assert_text)
assert assert_text=="热点要闻","不是热点新闻"
sleep(10)
diyishidian = driver.find_element(By.XPATH,'//*[@id="pane-news"]/div/ul/li[1]')
diyishidian.click()
sleep(10)
driver.close()
sleep(1000)
driver.quit()